<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<jsp:include page="../inc_min.jsp"></jsp:include>
<title>充值审核查询页面</title>
<link rel="stylesheet" href="${ctx}/css/page.css"/>
<link rel="stylesheet" href="${ctx}/css/iconfont.css"/>
<script type="text/javascript">
	$(function(){
		$(".listArg").click(function(){
			$(".listArg").css({
				"background": "#f1f1f1",
				"color": "black"
			});
			$(this).css({
				"background": "#28aaf0",
				"color": "#FFFFFF"
			});
			var conStatus=$(this).find("span").attr('id');
			getAjax(conStatus);
		});
		getAjax("");
		
		//点击查询
		$("#query").click(function(){
			var payOrderNumber=$("#_orderNumber").val();
			var buyer=$("#buyer").val();
			var startDate=$("#_startTime").val();
			var endDate=$("#_endTime").val();
            pageNum = 1;
			getAjax("");
		});
	});
	//封装函数  实现查询订单功能
	//全局变量 总页数
	var pageNum = 1;
	function getAjax(status){
		var pageSize = 20;
		var payOrderNumber=$("#_orderNumber").val();
		var buyer=$("#buyer").val();
		var startDate=$("#_startTime").val();
		var endDate=$("#_endTime").val();
		$.ajax({
			type:"get",
			url:"${ctx}/tradeList/checkPage?tradeType=3&rand="+Math.random()+"&payOrderNumber="+payOrderNumber
				+"&buyer="+buyer+"&startDate="+startDate+"&endDate="+endDate+"&status="+status+"&page="
				+pageNum+"&rows="+pageSize,
			async:true,
			success:function(data){
				$('table tbody').empty();
				var obj=data.rows;
				for(var i=0;i<obj.length;i++){
					var id=obj[i].id;
					var payOrderNumber=obj[i].payOrderNumber;//支付单号
					var organizationName=obj[i].organizationName;//采购商
					var createTime=obj[i].createTime//操作日期
					var accountBalance=obj[i].accountBalance;//账户余额
					var accountNumber=CommonConverter.toEmptyString(obj[i].accountNumber);//账号
					var accountName=CommonConverter.toEmptyString(obj[i].accountName);//账户名称
					var payType=CommonConverter.toPaystr(obj[i].payType);//支付方式
					var income=CommonConverter.toEmptyString(obj[i].income);//平台到账
					var tradeType=CommonConverter.toTradeStr(obj[i].tradeType);//交易类型
					var statusStr=CommonConverter.toRechargestr(obj[i].status);//状态
					var operation='<i class="icon iconfont position" title="详情" onclick=detail("'+id+'")>&#xe62d;</i>';
					if(obj[i].status == 0){
						operation='<i class="icon iconfont position" title="审核" onclick=check('+id+',\''+payOrderNumber+'\')>&#xe604;</i>';
					};
					tbody='<tr height="38" class="reBorder">'+
	             		  '<td width="219" align="center">支付单号：'+payOrderNumber+'</td>'+
	                  	   '<td width="1081" colspan="6" align="right" style="color:#fdc473;cursor:pointer;">'+
	                  	   operation+'</td>'+	   
	              		   '</tr>'+
							'<tr height="90"><td width="219" align="center" style="color:black;">'+organizationName+'</td>'+
							'<td width="173" align="center" style="color:black">'+createTime+'</td>'+
							'<td width="180" align="center" style="color:#e47470">￥'+accountBalance+'</td>'+
							'<td width="300" style="color:black">'+
							'<span style="margin-left:70px;">账号：'+accountNumber+'</span><br/>'+
							'<span style="margin-left:70px;">账号名称：'+accountName+'</span><br/>'+
							'<span style="margin-left:70px;">支付方式：'+payType+'</span><br/>'+
							'<span style="margin-left:70px;">平台到账：￥'+income+'</span></td>'+
							'<td width="238" align="center" style="color:black">'+tradeType+'</td>'+
							'<td width="100" align="center" ><span style="padding-left:20px;color:#e47470">'+statusStr+'</span></td>'+
							'</tr> '; 
					$("#tb").append(tbody);
				};
                //显示分页
                layui.use(['laypage', 'layer'], function(){
                    var laypage = layui.laypage;
                    laypage({
                        cont: 'pager'
                        ,pages:  Math.ceil(data.total/20) //得到总页数 //总页数
                        ,groups: 5 //连续显示分页数
                        ,skin: '#1E9FFF'
                        ,curr : pageNum
                        ,jump: function(obj,first){
                            if(!first){
                                pageNum = obj.curr;
                                getAjax(status);
                            }
                        }
                    });
                });
			}
		});
	};
	
	//查看
	function detail(id){
		layer.open({
			type: 2,
			title: ['审核','background-color:#00B2EE; color:#fff;'],
			shadeClose: true,
			shade: 0.5,
			area: ['500px', '300px'],
			content: ['${ctx}/np/checkPageDetail/'+id, 'no']
		});
	};
	//审核
	function check(id,number){
		layer.open({
			type: 2,
			title: ['审核','background-color:#00B2EE; color:#fff;'],
			shadeClose: true,
			shade: 0.5,
			area: ['500px', '400px'],
			content: ['${ctx}/np/checkPage/'+id, 'no'],
			end:function(){
				getAjax("");
			}
		});
	};
</script>
</head>
<body>
<jsp:include page="../head.jsp"/>
<div class="content">
			<ul class="list">
					<li>
						支付单号：<input  id="_orderNumber" name="charterType" />
					</li>
					<li>
						采购商：<input  id="buyer" name="charterType" />
					</li>
					<li>
						操作日期 ：<input class="textbox" id="_startTime" onclick="new WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width: 120px" />
						至<input class="textbox" id="_endTime" onclick="new WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width: 120px" />
					</li>
					<!-- <li>
						状态：
						<select id="status" style="width: 83px;">
							<option value="">全部</option>
							<option value="-1">审核不通过</option>
							<option value="0">待审核</option>
							<option value="1">已充值</option>
						</select>
					</li> -->
					<li class="right">
						<button class='query' id="query">查询</button>
					</li>
				</ul>
				 <ul class="list conditionList">
		         	<li>状态：</li>
					<li  class="listArg allStatus" >
						<span id=""/>全部</span>
					</li>
					<li class="listArg " >
						<span id="-1" >审核不通过</span>
					</li>
					<li class="listArg " >
						<span id="0">待审核</span>
					</li>
					<li class="listArg " >
						<span id="1">已充值</span>
					</li>
				</ul>
				<table class="conTable" >
					<thead>
						<tr height="38" >
							<td width="219" align="center">采购商</td>
							<td width="173" align="center">操作日期</td>
							<td width="233" align="center">账户余额</td>
							<td width="183" align="center">交易信息</td>
							<td width="238" align="center">类型</td>
							<td width="100" align="center"><span style="padding-left:20px;">状态</span></td>
						</tr>
					</thead>
					<tbody id="tb">
					</tbody> 
			</table>
    <!-- 分页 -->
    <div id="pager" class="divBox"></div>
		</div>
<jsp:include page="../footer.jsp"/>
</body>
</html>